package com.binfast.app.admin.controller;

import cn.hutool.log.Log;
import cn.hutool.log.LogFactory;
import com.binfast.app.admin.services.AdminRoleServ;
import com.binfast.bean.model.auth.AdminUser;
import com.binfast.bean.params.DetailParam;
import com.binfast.bean.params.adminRole.AdminRoleDetailSaveParam;
import com.binfast.bean.params.adminRole.AdminRoleListParam;
import com.binfast.common.util.Result;
import com.binfast.seed.base.BaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping(value = "/adminRole")
public class AdminRoleCtrl {
    private static final Log log = LogFactory.get();

    @Autowired
    AdminRoleServ adminRoleServ;

    @GetMapping(value = "/findList")
    public Result findList(@Validated AdminRoleListParam param) {
        AdminUser adminUser = new BaseService().getCurrentUser(AdminUser.class);
        return Result.success(adminRoleServ.findList(param));
    }
    @RequestMapping(value = "/getAllRoles",method = RequestMethod.POST)
    public Result getAllRoles() {
        return Result.success(adminRoleServ.getAllRoles());
    }

    @RequestMapping(value = "/findDetail",method = RequestMethod.POST)
    public Result findDetail (@Validated @RequestBody DetailParam param) {
        return Result.success(adminRoleServ.findDetail(param));
    }

    @RequestMapping(value = "/saveRole",method = RequestMethod.POST)
    public Result saveOne(@Validated @RequestBody AdminRoleDetailSaveParam param) {
        return Result.success(adminRoleServ.saveOne(param));
    }

    @RequestMapping(value = "/deleteRole",method = RequestMethod.POST)
    public Result deleteOne(@Validated @RequestBody DetailParam param) {
        return Result.success(adminRoleServ.deleteOne(param));
    }

}
